-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Devlin Lynch #4
base: main
Are you sure you want to change the base?
Devlin Lynch #4
Conversation
:price | ||
def initialize(item_info) | ||
@name = item_info[:name] | ||
@price = price_to_float(item_info[:price]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!!
@@ -1,3 +1,13 @@ | |||
class Item | |||
attr_reader :name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great git commit history!
|
||
def vendors_that_sell(item) | ||
vendor_list = @vendors.find_all do |vendor| | ||
vendor.inventory.include?(item) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great use of built in methods
|
||
def total_inventory | ||
inventory = {} | ||
@vendors.each do |vendor| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is probably an easier way to write this method! Could be worth asking chatgpt for refactor tips.
|
||
@market.add_vendor(@vendor2) | ||
@market.add_vendor(@vendor3) | ||
expect(@market.vendors).to eq([@vendor1,@vendor2,@vendor3]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love that you expect this works for one vendor, and multiples
expect(@vendor.inventory.keys).to eq([@item1]) | ||
|
||
@vendor.stock(@item2,20) | ||
expect(@vendor.inventory.keys).to eq([@item1,@item2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stock is tested in isolation - nice!
item_totals ={} | ||
@vendors.each do |vendor| | ||
vendor.inventory.each do |item,quantity| | ||
if item_totals[item] == nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great conditional logic checking the state of your hash.
No description provided.